package com.wyl.viewmodel

import android.os.Bundle
import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity
import androidx.databinding.DataBindingUtil
import com.wyl.viewmodel.databinding.ActivityViewmodelBinding

class ViewModelActivity : AppCompatActivity() {

    private val mainViewModel by viewModels<MyViewModel>()
    private lateinit var binding: ActivityViewmodelBinding

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
/*
        setContentView(R.layout.activity_viewmodel)

        mainViewModel.count.observe(this, Observer {
            textView.text = it
        })

        floatingActionButton.setOnClickListener {
            mainViewModel.addCount(1)
        }

        btStart.setOnClickListener {
            mainViewModel.startIncrease()
        }

        btStop.setOnClickListener {
            mainViewModel.stopIncrease()
        }
*/

        binding = DataBindingUtil.setContentView<ActivityViewmodelBinding>(
            this,
            R.layout.activity_viewmodel
        ).apply {
            lifecycleOwner = this@ViewModelActivity
            data = mainViewModel
        }
    }
}
